<!DOCTYPE HTML>
<html>

<head>
	<link rel="bookmark"  type="image/x-icon"  href="/img/logo_miccall.png"/>
	<link rel="shortcut icon" href="/img/logo_miccall.png">
	
			    <title>
    Ame雨
    </title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
    <link rel="stylesheet" href="/amelin-ting/css/mic_main.css" />
    <link rel="stylesheet" href="/amelin-ting/css/dropdownMenu.css" />
    <meta name="keywords" content="Ame雨" />
    
    	<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
	 
    <noscript>
        <link rel="stylesheet" href="/amelin-ting/css/noscript.css" />
    </noscript>
    <style type="text/css">
        body:before {
          content: ' ';
          position: fixed;
          top: 0;
          background: url('/amelin-ting/img/bg.jpg') center 0 no-repeat;
          right: 0;
          bottom: 0;
          left: 0;
          background-size: cover; 
        }
    </style>

			    
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script async type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


    <script src="/amelin-ting/js/jquery.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrollex.min.js"></script>
    <script src="/amelin-ting/js/jquery.scrolly.min.js"></script>
    <script src="/amelin-ting/js/skel.min.js"></script>
    <script src="/amelin-ting/js/util.js"></script>
    <script src="/amelin-ting/js/main.js"></script>
	
<meta name="generator" content="Hexo 5.4.0"></head>
    
		
<!-- Layouts -->



<!--  代码渲染  -->
<link rel="stylesheet" href="/css/prism_coy.css" />
<link rel="stylesheet" href="/css/typo.css" />
<!-- 文章页 -->
<body class="is-loading">
    <!-- Wrapper 外包 s-->
    <div id="wrapper" class="fade-in">
        <!-- Intro 头部显示 s -->
        <!-- Intro 头部显示 e -->
        <!-- Header 头部logo start -->
        <header id="header">
    <a href="/amelin-ting/" class="logo">Art Space</a>
</header>
        <!-- Nav 导航条 start -->
        <nav id="nav" class="special" >
            <ul class="menu links" >
			<!-- Homepage  主页  --> 
			<li >
	            <a href="/amelin-ting/" rel="nofollow">主页</a>
	        </li>
			<!-- categories_name  分类   --> 
	        
	        <li class="active">
	            <a href="#s1">分类</a>
	                    <ul class="submenu">
	                        <li>
	                        <a class="category-link" href="/amelin-ting/categories/Go/">Go</a></li><li><a class="category-link" href="/amelin-ting/categories/django/">django</a></li><li><a class="category-link" href="/amelin-ting/categories/drf/">drf</a></li><li><a class="category-link" href="/amelin-ting/categories/gin/">gin</a></li><li><a class="category-link" href="/amelin-ting/categories/go/">go</a></li><li><a class="category-link" href="/amelin-ting/categories/linux/">linux</a></li><li><a class="category-link" href="/amelin-ting/categories/mysql/">mysql</a></li><li><a class="category-link" href="/amelin-ting/categories/python/">python</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F/">内网穿透</a></li><li><a class="category-link" href="/amelin-ting/categories/%E5%89%8D%E7%AB%AF/">前端</a>
	                    </ul>
	        </li>
	        
	        <!-- archives  归档   --> 
	        
	        
		        <!-- Pages 自定义   -->
		        
		        <li>
		            <a href="/about/" title="简历">
		                简历
		            </a>
		        </li>
		        
		        <li>
		            <a href="/group/" title="团队">
		                团队
		            </a>
		        </li>
		        
		        <li>
		            <a href="/gallery/" title="图库">
		                图库
		            </a>
		        </li>
		        
		        <li>
		            <a href="/tag/" title="标签">
		                标签
		            </a>
		        </li>
		        


            </ul>
            <!-- icons 图标   -->
			<ul class="icons">
                    
                    <li>
                        <a title="github" href="https://github.com/miccall" target="_blank" rel="noopener">
                            <i class="icon fa fa-github"></i>
                        </a>
                    </li>
                    
                    <li>
                        <a title="500px" href="http://500px.com" target="_blank" rel="noopener">
                            <i class="icon fa fa-500px"></i>
                        </a>
                    </li>
                    
			</ul>
</nav>

        <div id="main" >
            <div class ="post_page_title_img" style="height: 25rem;background-image: url(https://img1.baidu.com/it/u=232034808,1680946842&amp;fm=26&amp;fmt=auto);background-position: center; background-repeat:no-repeat; background-size:cover;-moz-background-size:cover;overflow:hidden;" >
                <a href="#" style="padding: 4rem 4rem 2rem 4rem ;"><h2 >Go-grafana</h2></a>
            </div>
            <!-- Post -->
            <div class="typo" style="padding: 3rem;">
                <h2 id="一、grafana是什么"><a href="#一、grafana是什么" class="headerlink" title="一、grafana是什么"></a>一、grafana是什么</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">展示数据的工具，监控数据可视化</span><br><span class="line">nohup 能让linux一直运行一个可执行文件</span><br></pre></td></tr></table></figure>

<h2 id="二、grafana流程"><a href="#二、grafana流程" class="headerlink" title="二、grafana流程"></a>二、grafana流程</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 看官方教程把= =自己摸索摸索</span></span><br></pre></td></tr></table></figure>

<h2 id="三、通过Go和influxdb监控cpu负载"><a href="#三、通过Go和influxdb监控cpu负载" class="headerlink" title="三、通过Go和influxdb监控cpu负载"></a>三、通过Go和influxdb监控cpu负载</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span>(</span><br><span class="line">	<span class="string">&quot;fmt&quot;</span></span><br><span class="line">	client <span class="string">&quot;github.com/influxdata/influxdb1-client/v2&quot;</span></span><br><span class="line">	<span class="string">&quot;github.com/shirou/gopsutil/cpu&quot;</span></span><br><span class="line">	<span class="string">&quot;log&quot;</span></span><br><span class="line">	<span class="string">&quot;time&quot;</span></span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> (</span><br><span class="line">	cli client.Client</span><br><span class="line">)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">func</span> <span class="title">connInflux</span><span class="params">()</span> <span class="params">(err error)</span></span> &#123;</span><br><span class="line">	cli, err = client.NewHTTPClient(client.HTTPConfig&#123;</span><br><span class="line">		Addr:     <span class="string">&quot;http://127.0.0.1:8086&quot;</span>,</span><br><span class="line">		Username: <span class="string">&quot;admin&quot;</span>,</span><br><span class="line">		Password: <span class="string">&quot;&quot;</span>,</span><br><span class="line">	&#125;)</span><br><span class="line">	<span class="keyword">return</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">// insert</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">writesPoints</span><span class="params">(percent <span class="keyword">float64</span>)</span></span> &#123;</span><br><span class="line">        bp, err := client.NewBatchPoints(client.BatchPointsConfig&#123;</span><br><span class="line">            Database:  <span class="string">&quot;monitor&quot;</span>,</span><br><span class="line">            Precision: <span class="string">&quot;s&quot;</span>, <span class="comment">//精度，默认ns</span></span><br><span class="line">        &#125;)</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">        tags := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>&#123;<span class="string">&quot;cpu&quot;</span>: <span class="string">&quot;cpu0&quot;</span>&#125;</span><br><span class="line">        fields := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>&#123;&#125;&#123;</span><br><span class="line">            <span class="string">&quot;cpu_percent&quot;</span>:   percent,</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        pt, err := client.NewPoint(<span class="string">&quot;cpu_usage&quot;</span>, tags, fields, time.Now())</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">        bp.AddPoint(pt)</span><br><span class="line">        err = cli.Write(bp)</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">        log.Println(<span class="string">&quot;insert success&quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// cpu info</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">getCpuInfo</span><span class="params">()</span></span> &#123;</span><br><span class="line">        <span class="comment">// CPU使用率</span></span><br><span class="line">        percent, _ := cpu.Percent(time.Second, <span class="literal">false</span>)</span><br><span class="line">        fmt.Printf(<span class="string">&quot;cpu percent:%v\n&quot;</span>, percent)</span><br><span class="line">        writesPoints(percent[<span class="number">0</span>])</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">main</span><span class="params">()</span></span> &#123;</span><br><span class="line">        err := connInflux()</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            fmt.Println(err)</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">for</span> &#123;</span><br><span class="line">            getCpuInfo()</span><br><span class="line">            time.Sleep(time.Second)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>

<h2 id="四、通过Go和influxdb监控cpu-memory-desk-net"><a href="#四、通过Go和influxdb监控cpu-memory-desk-net" class="headerlink" title="四、通过Go和influxdb监控cpu memory desk net"></a>四、通过Go和influxdb监控cpu memory desk net</h2><figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// main.go</span></span><br><span class="line">    <span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line">    <span class="keyword">import</span> (</span><br><span class="line">        <span class="string">&quot;fmt&quot;</span></span><br><span class="line">        client <span class="string">&quot;github.com/influxdata/influxdb1-client/v2&quot;</span></span><br><span class="line">        <span class="string">&quot;github.com/shirou/gopsutil/cpu&quot;</span></span><br><span class="line">        <span class="string">&quot;github.com/shirou/gopsutil/disk&quot;</span></span><br><span class="line">        <span class="string">&quot;github.com/shirou/gopsutil/mem&quot;</span></span><br><span class="line">        <span class="string">&quot;github.com/shirou/gopsutil/net&quot;</span></span><br><span class="line">        <span class="string">&quot;log&quot;</span></span><br><span class="line">        <span class="string">&quot;time&quot;</span></span><br><span class="line">    )</span><br><span class="line"></span><br><span class="line">    <span class="keyword">var</span> (</span><br><span class="line">        cli client.Client <span class="comment">// 在全局变量声明</span></span><br><span class="line">        lastNetIOStatTimeStamp <span class="keyword">int64</span> <span class="comment">// 上一次获取网络IO数据的时间点</span></span><br><span class="line">        lastNetInfo *NetInfo <span class="comment">// 上一次的网络数据</span></span><br><span class="line">    )</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 封装err报错信息</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">errs</span><span class="params">(err error, str <span class="keyword">string</span>)</span></span> &#123;</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            log.Fatalf(<span class="string">&quot;%s err: %v&quot;</span>, str, err)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 连接influxdb</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">connInflux</span><span class="params">()</span> <span class="params">(err error)</span></span> &#123;</span><br><span class="line">        cli, err = client.NewHTTPClient(client.HTTPConfig&#123;</span><br><span class="line">            Addr:     <span class="string">&quot;http://127.0.0.1:8086&quot;</span>,</span><br><span class="line">            Username: <span class="string">&quot;admin&quot;</span>,</span><br><span class="line">            Password: <span class="string">&quot;&quot;</span>,</span><br><span class="line">        &#125;)</span><br><span class="line">        <span class="keyword">return</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 利用gopsutil包拿到CPU使用率</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">getCpuInfo</span><span class="params">()</span></span> &#123;</span><br><span class="line">        <span class="comment">// var一个CpuInfo对象</span></span><br><span class="line">        <span class="keyword">var</span> cpuInfo = <span class="built_in">new</span>(CpuInfo)</span><br><span class="line">        percent, _ := cpu.Percent(time.Second, <span class="literal">false</span>)</span><br><span class="line">        fmt.Printf(<span class="string">&quot;cpu percent:%v\n&quot;</span>, percent)</span><br><span class="line">        <span class="comment">// 拿到传给wcp的参数</span></span><br><span class="line">        cpuInfo.CpuPercent = percent[<span class="number">0</span>]</span><br><span class="line">        writesCpuPoints(cpuInfo)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 利用gopsutil包拿到Mem数据</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">getMemInfo</span><span class="params">()</span></span> &#123;</span><br><span class="line">        <span class="comment">// var一个CpuInfo对象</span></span><br><span class="line">        <span class="keyword">var</span> memInfo = <span class="built_in">new</span>(MemInfo)</span><br><span class="line">        vtMemoryStat, _ := mem.VirtualMemory()</span><br><span class="line">        fmt.Printf(<span class="string">&quot;mem info:%v\n&quot;</span>, memInfo)</span><br><span class="line">        <span class="comment">// 把属性一一对应</span></span><br><span class="line">        memInfo.Used = vtMemoryStat.Used</span><br><span class="line">        memInfo.Free = vtMemoryStat.Free</span><br><span class="line">        memInfo.Total = vtMemoryStat.Total</span><br><span class="line">        memInfo.Available = vtMemoryStat.Available</span><br><span class="line">        <span class="comment">// 将memInfo传入函数中</span></span><br><span class="line">        writesMemPoints(memInfo)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 利用gopsutil包拿到Disk数据</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">getDiskInfo</span><span class="params">()</span></span> &#123;</span><br><span class="line">        <span class="comment">// var并初始化对象</span></span><br><span class="line">        <span class="keyword">var</span> diskInfo = &amp;DiskInfo&#123;</span><br><span class="line">            PartitionUsageStat: <span class="built_in">make</span>(<span class="keyword">map</span>[<span class="keyword">string</span>]*disk.UsageStat, <span class="number">18</span>),</span><br><span class="line">        &#125;</span><br><span class="line">        parts, err := disk.Partitions(<span class="literal">true</span>)</span><br><span class="line">        errs(err, <span class="string">&quot;disk&quot;</span>)</span><br><span class="line">        <span class="comment">// 循环硬盘分区</span></span><br><span class="line">        <span class="keyword">for</span> _, part := <span class="keyword">range</span> parts &#123;</span><br><span class="line">            usageStat, err := disk.Usage(part.Mountpoint)</span><br><span class="line">            <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">                fmt.Printf(<span class="string">&quot;get Partitions failed, err:%v\n&quot;</span>, err)</span><br><span class="line">                <span class="keyword">continue</span> <span class="comment">// 这个分区不行了，跳过下一个分区</span></span><br><span class="line">            &#125;</span><br><span class="line">            diskInfo.PartitionUsageStat[part.Mountpoint] = usageStat</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 写入</span></span><br><span class="line">        writesDiskPoints(diskInfo)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 利用gopsutil包拿到Net数据，但是我们要直接数据没有用，所以我们要处理成网卡的速率</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">getNetInfo</span><span class="params">()</span></span> &#123;</span><br><span class="line">        <span class="keyword">var</span> netInfo = &amp;NetInfo&#123;</span><br><span class="line">            NetIOCountersStat: <span class="built_in">make</span>(<span class="keyword">map</span>[<span class="keyword">string</span>]*IOStat, <span class="number">8</span>),</span><br><span class="line">        &#125;</span><br><span class="line">        currentTimeStamp := time.Now().Unix()</span><br><span class="line">        netIOs, err := net.IOCounters(<span class="literal">true</span>)</span><br><span class="line"></span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            fmt.Printf(<span class="string">&quot;get net io counters err:&quot;</span>, err)</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">for</span> _, netIO := <span class="keyword">range</span> netIOs &#123;</span><br><span class="line">            <span class="keyword">var</span> ioStat = <span class="built_in">new</span>(IOStat)</span><br><span class="line">            ioStat.BytesSent = netIO.BytesSent</span><br><span class="line">            ioStat.BytesRecv = netIO.BytesRecv</span><br><span class="line">            ioStat.PacketsSent = netIO.PacketsSent</span><br><span class="line">            ioStat.PacketsRecv = netIO.PacketsRecv</span><br><span class="line">            <span class="comment">// 将具体网卡数据的ioStat变量添加到map中</span></span><br><span class="line">            netInfo.NetIOCountersStat[netIO.Name] = ioStat</span><br><span class="line">            <span class="comment">// 开始计算网卡每秒速率</span></span><br><span class="line">            <span class="keyword">if</span> lastNetIOStatTimeStamp == <span class="number">0</span> || lastNetInfo == <span class="literal">nil</span> &#123;</span><br><span class="line">                <span class="keyword">continue</span></span><br><span class="line">            &#125;</span><br><span class="line">            intervel := currentTimeStamp - lastNetIOStatTimeStamp</span><br><span class="line">            ioStat.BytesSentRate = (<span class="keyword">float64</span>(ioStat.BytesSent) - <span class="keyword">float64</span>(lastNetInfo.NetIOCountersStat[netIO.Name].BytesSent))/<span class="keyword">float64</span>(intervel)</span><br><span class="line">            ioStat.BytesRecvRate = (<span class="keyword">float64</span>(ioStat.BytesRecv) - <span class="keyword">float64</span>(lastNetInfo.NetIOCountersStat[netIO.Name].BytesRecv))/<span class="keyword">float64</span>(intervel)</span><br><span class="line">            ioStat.PacketsSentRate = (<span class="keyword">float64</span>(ioStat.PacketsSent) - <span class="keyword">float64</span>(lastNetInfo.NetIOCountersStat[netIO.Name].PacketsSent))/<span class="keyword">float64</span>(intervel)</span><br><span class="line">            ioStat.PacketsRecvRate = (<span class="keyword">float64</span>(ioStat.PacketsRecv) - <span class="keyword">float64</span>(lastNetInfo.NetIOCountersStat[netIO.Name].PacketsRecv))/<span class="keyword">float64</span>(intervel)</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 更新全局记录的上一次采集网卡的时间点和网卡数据</span></span><br><span class="line">        lastNetIOStatTimeStamp = currentTimeStamp</span><br><span class="line">        lastNetInfo = netInfo</span><br><span class="line">        <span class="comment">// 发送到influxdb</span></span><br><span class="line">        writesNetPoints(netInfo)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//model.go</span></span><br><span class="line">    <span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line">    <span class="keyword">import</span> <span class="string">&quot;github.com/shirou/gopsutil/disk&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 定义系统信息类型常量</span></span><br><span class="line">    <span class="keyword">const</span> (</span><br><span class="line">        CpuInfoType  = <span class="string">&quot;cpu&quot;</span></span><br><span class="line">        MemInfoType  = <span class="string">&quot;mem&quot;</span></span><br><span class="line">        DiskInfoType = <span class="string">&quot;disk&quot;</span></span><br><span class="line">        NetInfoType  = <span class="string">&quot;net&quot;</span></span><br><span class="line">    )</span><br><span class="line"></span><br><span class="line">    <span class="comment">// SysInfo 定义一个概括系统信息的结构体</span></span><br><span class="line">    <span class="keyword">type</span> SysInfo <span class="keyword">struct</span> &#123;</span><br><span class="line">        InfoType <span class="keyword">string</span></span><br><span class="line">        IP       <span class="keyword">string</span></span><br><span class="line">        Data     <span class="keyword">interface</span>&#123;&#125; <span class="comment">// 因为类型不确定 用空接口</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// CpuInfo 定义一个Cpu结构体</span></span><br><span class="line">    <span class="keyword">type</span> CpuInfo <span class="keyword">struct</span> &#123;</span><br><span class="line">        CpuPercent <span class="keyword">float64</span> <span class="string">`json:&quot;cpu_percent&quot;`</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// MemInfo 定义一个Mem结构体</span></span><br><span class="line">    <span class="keyword">type</span> MemInfo <span class="keyword">struct</span> &#123;</span><br><span class="line">        <span class="comment">// Total 系统中RAM的总量 RAM: 随机存取存储器 也叫主存</span></span><br><span class="line">        Total <span class="keyword">uint64</span> <span class="string">`json:&quot;total&quot;`</span></span><br><span class="line">        <span class="comment">// 可用于程序分配的RAM</span></span><br><span class="line">        Available <span class="keyword">uint64</span> <span class="string">`json:&quot;available&quot;`</span></span><br><span class="line">        <span class="comment">// 程序使用的RAM</span></span><br><span class="line">        Used <span class="keyword">uint64</span> <span class="string">`json:&quot;used&quot;`</span></span><br><span class="line">        <span class="comment">// 内核的空余内存</span></span><br><span class="line">        Free <span class="keyword">uint64</span> <span class="string">`json:&quot;free&quot;`</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// DiskInfo 定义一个Disk结构体</span></span><br><span class="line">    <span class="keyword">type</span> DiskInfo <span class="keyword">struct</span> &#123;</span><br><span class="line">        PartitionUsageStat <span class="keyword">map</span>[<span class="keyword">string</span>]*disk.UsageStat</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// IOStat 定义一个IOStat类型</span></span><br><span class="line">    <span class="keyword">type</span> IOStat <span class="keyword">struct</span> &#123;</span><br><span class="line">        BytesSent   <span class="keyword">uint64</span> <span class="string">`json:&quot;bytesSent&quot;`</span>   <span class="comment">// number of bytes sent</span></span><br><span class="line">        BytesRecv   <span class="keyword">uint64</span> <span class="string">`json:&quot;bytesRecv&quot;`</span>   <span class="comment">// number of bytes received</span></span><br><span class="line">        PacketsSent <span class="keyword">uint64</span> <span class="string">`json:&quot;packetsSent&quot;`</span> <span class="comment">// number of packets sent</span></span><br><span class="line">        PacketsRecv <span class="keyword">uint64</span> <span class="string">`json:&quot;packetsRecv&quot;`</span> <span class="comment">// number of packets received</span></span><br><span class="line">        BytesSentRate   <span class="keyword">float64</span> <span class="string">`json:&quot;bytesSentRate&quot;`</span>   <span class="comment">// number of bytes sent</span></span><br><span class="line">        BytesRecvRate  <span class="keyword">float64</span> <span class="string">`json:&quot;bytesRecvRate&quot;`</span>   <span class="comment">// number of bytes received</span></span><br><span class="line">        PacketsSentRate <span class="keyword">float64</span> <span class="string">`json:&quot;packetsSentRate&quot;`</span> <span class="comment">// number of packets sent</span></span><br><span class="line">        PacketsRecvRate <span class="keyword">float64</span> <span class="string">`json:&quot;packetsRecvRate&quot;`</span> <span class="comment">// number of packets received</span></span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// NetInfo 把IOStat封装成map 方便管理</span></span><br><span class="line">    <span class="keyword">type</span> NetInfo <span class="keyword">struct</span> &#123;</span><br><span class="line">        NetIOCountersStat <span class="keyword">map</span>[<span class="keyword">string</span>]*IOStat</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// write_2_influxdb</span></span><br><span class="line">    <span class="keyword">package</span> main</span><br><span class="line"></span><br><span class="line">    <span class="keyword">import</span> (</span><br><span class="line">        client <span class="string">&quot;github.com/influxdata/influxdb1-client/v2&quot;</span></span><br><span class="line">        <span class="string">&quot;log&quot;</span></span><br><span class="line">        <span class="string">&quot;time&quot;</span></span><br><span class="line">    )</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 把error封装成函数，避免冗余代码，影响可读性</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">errors</span><span class="params">(err error)</span></span> &#123;</span><br><span class="line">        <span class="keyword">if</span> err != <span class="literal">nil</span> &#123;</span><br><span class="line">            log.Fatal(err)</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="comment">// 拿到cpu数据发送给influxdb数据库</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">writesCpuPoints</span><span class="params">(data *CpuInfo)</span></span> &#123;</span><br><span class="line">        bp, err := client.NewBatchPoints(client.BatchPointsConfig&#123;</span><br><span class="line">            Database:  <span class="string">&quot;ame&quot;</span>, <span class="comment">// 选择库</span></span><br><span class="line">            Precision: <span class="string">&quot;s&quot;</span>,   <span class="comment">//精度，默认ns</span></span><br><span class="line">        &#125;)</span><br><span class="line">        errors(err)</span><br><span class="line">        tags := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>&#123;<span class="string">&quot;cpu&quot;</span>: <span class="string">&quot;cpu&quot;</span>&#125; <span class="comment">// 设置标签</span></span><br><span class="line">        fields := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>&#123;&#125;&#123; <span class="comment">// 采集的信息</span></span><br><span class="line">            <span class="string">&quot;cpu_percent&quot;</span>: data.CpuPercent,</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        pt, err := client.NewPoint(<span class="string">&quot;cpu_percent&quot;</span>, tags, fields, time.Now())</span><br><span class="line">        errors(err)</span><br><span class="line">        bp.AddPoint(pt)</span><br><span class="line"></span><br><span class="line">        err = cli.Write(bp)</span><br><span class="line">        errors(err)</span><br><span class="line">        log.Println(<span class="string">&quot;CPU insert success&quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 拿到Mem数据发送给influxdb数据库</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">writesMemPoints</span><span class="params">(data *MemInfo)</span></span> &#123;</span><br><span class="line">        bp, err := client.NewBatchPoints(client.BatchPointsConfig&#123;</span><br><span class="line">            Database:  <span class="string">&quot;ame&quot;</span>, <span class="comment">// 选择库</span></span><br><span class="line">            Precision: <span class="string">&quot;s&quot;</span>,   <span class="comment">//精度，默认ns</span></span><br><span class="line">        &#125;)</span><br><span class="line">        errors(err)</span><br><span class="line">        tags := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>&#123;<span class="string">&quot;Mem&quot;</span>: <span class="string">&quot;mem&quot;</span>&#125; <span class="comment">// 设置标签</span></span><br><span class="line">        fields := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>&#123;&#125;&#123; <span class="comment">// 采集的信息</span></span><br><span class="line">            <span class="string">&quot;total&quot;</span>:     <span class="keyword">int64</span>(data.Total),</span><br><span class="line">            <span class="string">&quot;available&quot;</span>: <span class="keyword">int64</span>(data.Available),</span><br><span class="line">            <span class="string">&quot;used&quot;</span>:      <span class="keyword">int64</span>(data.Used),</span><br><span class="line">            <span class="string">&quot;free&quot;</span>:      <span class="keyword">int64</span>(data.Free),</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        pt, err := client.NewPoint(<span class="string">&quot;Memory&quot;</span>, tags, fields, time.Now())</span><br><span class="line">        errors(err)</span><br><span class="line">        bp.AddPoint(pt)</span><br><span class="line"></span><br><span class="line">        err = cli.Write(bp)</span><br><span class="line">        errors(err)</span><br><span class="line">        log.Println(<span class="string">&quot;Mem insert success&quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 拿到Disk数据发送给influxdb数据库</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">writesDiskPoints</span><span class="params">(data *DiskInfo)</span></span> &#123;</span><br><span class="line">        bp, err := client.NewBatchPoints(client.BatchPointsConfig&#123;</span><br><span class="line">            Database:  <span class="string">&quot;ame&quot;</span>, <span class="comment">// 选择库</span></span><br><span class="line">            Precision: <span class="string">&quot;s&quot;</span>,   <span class="comment">//精度，默认ns</span></span><br><span class="line">        &#125;)</span><br><span class="line">        errors(err)</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 循环遍历去除map中的key:value</span></span><br><span class="line">        <span class="keyword">for</span> k, v := <span class="keyword">range</span> data.PartitionUsageStat &#123;</span><br><span class="line">            tags := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>&#123;<span class="string">&quot;path&quot;</span>: k&#125; <span class="comment">// 设置标签</span></span><br><span class="line">            fields := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>&#123;&#125;&#123; <span class="comment">// 采集的信息</span></span><br><span class="line">                <span class="string">&quot;total&quot;</span>: <span class="keyword">int64</span>(v.Total),</span><br><span class="line">                <span class="string">&quot;free&quot;</span>:  <span class="keyword">int64</span>(v.Free),</span><br><span class="line">                <span class="string">&quot;user&quot;</span>:  <span class="keyword">int64</span>(v.Used),</span><br><span class="line">            &#125;</span><br><span class="line">            pt, err := client.NewPoint(<span class="string">&quot;Disk&quot;</span>, tags, fields, time.Now())</span><br><span class="line">            errors(err)</span><br><span class="line">            bp.AddPoint(pt)</span><br><span class="line">        &#125;</span><br><span class="line">        err = cli.Write(bp)</span><br><span class="line">        errors(err)</span><br><span class="line">        log.Println(<span class="string">&quot;Disk insert success&quot;</span>)</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 拿到Net数据发送给influxdb数据库</span></span><br><span class="line">    <span class="function"><span class="keyword">func</span> <span class="title">writesNetPoints</span><span class="params">(data *NetInfo)</span></span> &#123;</span><br><span class="line">        bp, err := client.NewBatchPoints(client.BatchPointsConfig&#123;</span><br><span class="line">            Database:  <span class="string">&quot;ame&quot;</span>,</span><br><span class="line">            Precision: <span class="string">&quot;s&quot;</span>, <span class="comment">//精度，默认ns</span></span><br><span class="line">        &#125;)</span><br><span class="line">        errors(err)</span><br><span class="line">        <span class="comment">// 循环在map取出key:value 跟disk思路一致</span></span><br><span class="line">        <span class="keyword">for</span> k, v := <span class="keyword">range</span> data.NetIOCountersStat &#123;</span><br><span class="line">            tags := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">string</span>&#123;<span class="string">&quot;name&quot;</span>: k&#125; <span class="comment">// 把每个网卡按名字建立索引</span></span><br><span class="line">            fields := <span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>&#123;&#125;&#123;</span><br><span class="line">                <span class="string">&quot;bytesSentRate&quot;</span>: v.BytesSentRate,</span><br><span class="line">                <span class="string">&quot;bytesRecvRate&quot;</span>: v.BytesRecvRate,</span><br><span class="line">                <span class="string">&quot;packetsSentRate&quot;</span>: v.PacketsSentRate,</span><br><span class="line">                <span class="string">&quot;packetsRecvRate&quot;</span>: v.PacketsRecvRate,</span><br><span class="line">            &#125;</span><br><span class="line">            pt, err := client.NewPoint(<span class="string">&quot;net&quot;</span>, tags, fields, time.Now())</span><br><span class="line">            errors(err)</span><br><span class="line">            bp.AddPoint(pt)</span><br><span class="line">        &#125;</span><br><span class="line">        err = cli.Write(bp)</span><br><span class="line">        errors(err)</span><br><span class="line">        log.Println(<span class="string">&quot;Net insert success&quot;</span>)</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>


            </div>

            <!-- Post Comments -->
            
    <!-- 使用 DISQUS_CLICK -->
<div id="disqus-comment">
    <div id="disqus_thread"></div>

<!-- add animation -->
<style>
	.disqus_click_btn {
            line-height: 30px;
            margin: 0;
            min-width: 50px;
            padding: 0 14px;
            display: inline-block;
            font-family: "Roboto", "Helvetica", "Arial", sans-serif;
            font-size: 14px;
            font-weight: 400;
            text-transform: uppercase;
            letter-spacing: 0;
            overflow: hidden;
            will-change: box-shadow;
            transition: box-shadow .2s cubic-bezier(.4, 0, 1, 1), background-color .2s cubic-bezier(.4, 0, .2, 1), color .2s cubic-bezier(.4, 0, .2, 1);
            outline: 0;
            cursor: pointer;
            text-decoration: none;
            text-align: center;
            vertical-align: middle;
            border: 0;
            background: rgba(158, 158, 158, .2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
            color: #fff;
            background-color: #7EC0EE;
            text-shadow: 0
        }
</style>
	
<div class="btn_click_load" id="disqus_bt"> 
    <button class="disqus_click_btn">点击查看评论</button>
</div>

<!--
<script type="text/javascript">
$('.btn_click_load').click(function() {
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'http-miccall-tech'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();

    document.getElementById('disqus_bt').style.display = "none";
});
</script>
-->
<script type="text/javascript">
    var disqus_config = function () {
        this.page.url = 'https://gitee.com/AmeX/amelin-ting.git/2020/05/25/Go------grafana/';  // Replace PAGE_URL with your page's canonical URL variable
        this.page.identifier = 'https://gitee.com/AmeX/amelin-ting.git/2020/05/25/Go------grafana/'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
    };
</script>

<script type="text/javascript">
    $('.btn_click_load').click(function() {  //click to load comments
        (function() { // DON'T EDIT BELOW THIS LINE
            var d = document;
            var s = d.createElement('script');
            s.src = '//http-miccall-tech.disqus.com/embed.js';
            s.setAttribute('data-timestamp', + new Date());
            (d.head || d.body).appendChild(s);
        })();
        $('.btn_click_load').css('display','none');
    });
</script>
</div>
<style>
    #disqus-comment{
        background-color: #eee;
        padding: 2pc;
    }
</style>


        </div>
        <!-- Copyright 版权 start -->
                <div id="copyright">
            <ul>
                <li>&copy;Powered By <a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/" style="border-bottom: none;">hexo</a></li>
                <li>Design: <a target="_blank" rel="noopener" href="http://miccall.tech " style="border-bottom: none;">miccall</a></li>
            </ul>
            
                <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
			
        </div>
    </div>
</body>



 	
</html>
